<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="/struts-tags" prefix="s" %>

<s:if test="user==null">
    <s:set name="title" value="Add User"/>
</s:if>
<s:else>
    <s:set name="title" value="Update User"/>
</s:else>
<html>
    <head>
        <link href="<c:url value='/css/main.css'/>" rel="stylesheet" type="text/css"/>
        <style>td { white-space:nowrap; }</style>
        <title><s:property value="title"/></title>
    </head>
    <body>
        
        <h1><s:property value="#title"/></h1>
        <s:form namespace="/user" action="update_%{user.username}">
			<s:actionerror/>
            <table>
                <tr>
                    
                    <td><s:textfield name="user.username" size="30" readonly="update" label="username"/> 
                        <s:fielderror><s:param>user.username</s:param></s:fielderror></td>
                </tr>
                <tr>
                   
                    <td><s:password name="user.password" size="30" label="password"/> 
                    <s:fielderror><s:param>user.password</s:param></s:fielderror></td>
                </tr>
                <tr>
                   
                    <td><s:textfield name="user.email" size="40" label="email"/> 
                    <s:fielderror><s:param>user.email</s:param></s:fielderror></td>
                </tr>
                <tr>
                   
                    <td>
                        <s:select name="user.role" list="{'admin','lecturer','student'}" label="role"/>
                    </td>
                </tr>
                <tr>
                    <td colspan="2">
                        <s:hidden key="update"/>
                        <br/>
                        <s:submit label="submit"/>
                        
                        &nbsp;&nbsp;&nbsp;
                        <s:submit label="cancel" action="user_list_all"/>
                    </td>
                </tr>
            </table>
        </s:form>
    </body>
</html>